<script type="text/javascript">
    //自动有效日期
    $(document).on('afterchange.bjui.datepicker', '.j_custom_issuedate', function(e, data) {
        var pattern = 'yyyy-MM-dd'
        var start   = end = data.value
        var $end    = $(this).closest('tr').find('.j_custom_indate')

        if ($end.length) {
            end.setFullYear(start.getFullYear() + 10)
            end.setDate(start.getDate() - 1)
            $end.val(end.formatDate(pattern))
        }
    })
    //上传图片完成回调
    function custom_pic_upload_success(file, data, $upload) {
        var json = $.parseJSON(data);
//        $upload.parent().parent().find("input[name='name']").val("223");
        if (json[BJUI.keys.statusCode] == BJUI.statusCode.ok) {
            $upload.parent().parent().find("input[name='artifactName']").val(json.originalName);
            $upload.parent().parent().find("input[name='artifactSize']").val(json.size);
            $upload.parent().parent().find("input[name='artifactIdArray']").val(json.artifactId);
//            $upload.parent().parent().find("input[name='warnFlag']").val(json.warnFlag);
            if(json.warnFlag)
            {
                $upload.parent().parent().find("input[name='warnFlag']").val("是");
                $upload.parent().parent().find("input[name='warnFlag']").css("background-color","red");
            }
            else
            {
                $upload.parent().parent().find("input[name='warnFlag']").css("background-color","");
                $upload.parent().parent().find("input[name='warnFlag']").val("否");
            }

//            var pic = json.navTabId
//
//            $upload.next().val(pic).next().html('<img src="'+ pic +'" width="80" />')
        }
    }
    //删除回调
    $('#tabledit1').on('afterdelete.bjui.tabledit', function(e) {
        var $tbody = $(e.relatedTarget)

//        console.log('你删除了一条数据，还有['+ $tbody.find('> tr').length +']条数据！')
    })
</script>
<table id="tabledit1" class="table table-bordered table-hover table-striped table-top" data-toggle="tabledit" data-initnum="0" data-action="ajaxDone3.html" data-single-noindex="true">
    <thead>
    <tr data-idname="customList[#index#].id">
        <th title="文件名"><input type="text" name="artifactName" data-rule="required" value="" size="10" readonly></th>
        <th title="文件大小"><input type="text" name="artifactSize" data-rule="required" value="" size="10" readonly></th>
        <th title="文件ID"><input type="text" name="artifactIdArray" data-rule="required" value="" size="10" readonly></th>
        <th title="危险提示"><input type="text" name="warnFlag" data-rule="required" value="" size="10" readonly ></th>
        <th title="文件上传">
            <div id="fileInput-custom-i[#index#]"
                 data-toggle="upload"
                 data-uploader="${wwwroot}/admin/artifact/upload"
                 data-file-size-limit="1024000000"
                 data-file-type-exts="<#list uploadFormats as format>*.${(format.format)!};</#list>"
                 data-multi="false"
                 data-auto="true"
                 data-on-upload-success="custom_pic_upload_success"></div>
                <#--<input type="hidden" name="artifactIdArray"  value="">-->
            <input type="hidden" name="customList[#index#].pic" class="pic-name" value=""><span class="pic-box"></span>
        </th>
        <th title="是否发布">
            <select name="isDeploy" data-toggle="selectpicker" data-rule="required">
                <option value="1">是</option>
                <option value="0">否</option>
            </select>
        </th>
        <th title="" data-addtool="true" width="100">
            <a href="javascript:;" class="btn btn-red row-del" data-confirm-msg="确定要删除该行信息吗？">删</a>
        </th>
    </tr>
    </thead>
    <tbody>
    <#if subjectArtifacts??>
        <#list subjectArtifacts as subjectArtifact>

            <tr data-id="$((subjectArtifact_index+1)!)" >
                <td data-val="${subjectArtifact.artifactName}"></td>
                <td data-val="${subjectArtifact.artifactSize}">
                <td data-val="${subjectArtifact.artifactId}"></td>
                <td  <#if subjectArtifact.warnFlag>style="background-color:red"</#if>  data-val="<#if subjectArtifact.warnFlag>是<#else>否</#if>">

                </td>
                <#--
                <td><input type="hidden" name="artifactIdArray"  value="${subjectArtifact.artifactId}"></td>
                -->
                <td></td>
                <#if subjectArtifact.isDeploy>
                    <td data-val="1"></td>
                <#else>
                    <td data-val="0"></td>
                </#if>
                <td data-noedit="true">
                    <a href="javascript:;" class="btn btn-red row-del" data-confirm-msg="确定要删除该行信息吗？">删</a>
                    <a href="/file/${(subjectArtifact.artifactId)!}" target="_blank">预览</a>
                </td>
            </td>
        </#list>
    </#if>


    </tbody>
</table>
